package com.gwz.bus.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gwz.bus.service.OutportService;
import com.gwz.bus.vo.OutportVo;
import com.gwz.sys.utils.DataGridView;
import com.gwz.sys.utils.ResultObj;
import com.gwz.sys.utils.WebUtils;

@RestController
@RequestMapping("outport")
public class OutportController {

	@Autowired
	private OutportService outportService;
	
	/**
	 * 加载退货列表
	 */
	@RequestMapping("loadAllOutports")
	public DataGridView loadAllOutports(OutportVo outportVo) {
		return this.outportService.queryAllOutports(outportVo);
	}
	
	/**
	 * 添加
	 */
	@RequestMapping("addOutport")
	public ResultObj addOutport(OutportVo outportVo){
		try {
			outportVo.setOutporttime(new Date());
			outportVo.setOperateperson(WebUtils.getCurrentUser().getName());
			this.outportService.addOutport(outportVo);
			return new ResultObj(200, "添加成功");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new ResultObj(-1, "添加失败");
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("deleteOutport")
	public ResultObj deleteOutport(OutportVo outportVo){
		try {
			//做删除
			this.outportService.deleteOutport(outportVo.getId());
			return new ResultObj(200, "删除成功");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new ResultObj(-1, "修改失败");
	}
}
